from PIL import Image, ImageFilter, ImageOps

'''
 将文件转化为黑白照
'''


def dodge(a, b, alpha):
    return min( int( a * 255 / (256 - b * alpha) ), 255 )


def draw(img, blur=25, alpha=0.1):
    img1 = img.convert( 'L' )
    img2 = img1.copy()
    img2 = ImageOps.invert( img2 )
    for i in range( blur ):
        img2 = img2.filter( ImageFilter.BLUR )
    width, height = img1.size
    for x in range( width ):
        for y in range( height ):
            a = img1.getpixel( (x, y) )
            b = img2.getpixel( (x, y) )
            img1.putpixel( (x, y), dodge( a, b, alpha ) )
    img1.show()
    img1.save( '/Users/xuyihang/Downloads/kongli.png' )


if __name__ == '__main__':
    i = -3 + -3
    print(i)
# img = Image.open( '/Users/xuyihang/Downloads/行政中心所有人员照片/孔莉 000026.png' )
# draw( img )
